package stdio.costa.imoca.converter;

import stdio.costa.imoca.model.MocaAccessToken;
import stdio.costa.imoca.model.MocaUser;
import stdio.costa.imoca.utils.Constants;

public class MocaUser2MocaAccessToken {

	public static MocaAccessToken convert(MocaUser user) {

		if (user == null) {
			return null;
		}

		MocaAccessToken mocaAccessToken = new MocaAccessToken();

		mocaAccessToken.setUid(user.getUuid());

		StringBuilder token = new StringBuilder(Constants.MOCA).append(Constants.SPLITER)
				.append(user.getUuid()).append(Constants.SPLITER)
				.append(user.getPassword());
		
		mocaAccessToken.setAccessToken(token.toString());
		
		return mocaAccessToken;

	}
}
